﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FisheryPlatform.Bussiness.WebRuntime;
using FisheryPlatform.Bussiness.Cache;

namespace FisheryPlatform.Web.Admin.Settings
{
    /// <summary>
    /// SetingsAction 的摘要说明
    /// </summary>
    public class SettingsAction : HttpHandlerBase, IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            base.Init(context);
            AjaxActionResult result = new AjaxActionResult();
            if (string.IsNullOrEmpty(FormValue("at")) == false)
            {
                switch (FormValue("at").Trim())
                {
                    case "cache": CacheAction(result); break;
                    default: break;
                }
            }
            base.SerializeDataToResponseStream(result);
        }

        private void CacheAction(AjaxActionResult result)
        {
            var keys = FormValue("cacheKeys");
            SiteCacheManager.RemoveCache(SiteCacheManager.SiteNameWWW, keys);
            result.success = true;
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}